{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 语音识别（Speech Recognition)\n",
    "\n",
    "* 本周主要内容：语音识别（Speech Recognition）\n",
    "* 20春_API_人工智能与机器学习_week08\n",
    "*  电子讲义设计者：许智超，廖汉腾\n",
    "<br/>\n",
    "<br/>\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "----\n",
    "\n",
    "\n",
    "<br/>\n",
    "<br/>\n",
    "\n",
    "\n",
    "# 本周内容介绍\n",
    "\n",
    "\n",
    "## 语音识别 & 语音合成\n",
    "\n",
    "* 什么是语音识别 [一分钟看懂语音识别](https://zhuanlan.zhihu.com/p/30932217)\n",
    "\n",
    "* 语音合成\n",
    "\n",
    "\n",
    "## 实践：上课视频如何转文本\n",
    "\n",
    "* vieo->audio->API--> text\n",
    "\n",
    "\n",
    "## 思考和额外练习：如何把图灵微信公众号文本自动回复转变成语音自动回复？\n",
    "\n",
    "## 产品经理如何绕开API的坑\n",
    "\n",
    "## 产品经理如何阅读API文档\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "%%html\n",
    "<style>\n",
    "/* 本电子讲义使用之CSS */\n",
    "div.code_cell {\n",
    "    background-color: #e5f1fe;\n",
    "}\n",
    "div.cell.selected {\n",
    "    background-color: #effee2;\n",
    "    font-size: 2rem;\n",
    "    line-height: 2.4rem;\n",
    "}\n",
    "div.cell.selected .rendered_html table {\n",
    "    font-size: 2rem !important;\n",
    "    line-height: 2.4rem !important;\n",
    "}\n",
    ".rendered_html pre code {\n",
    "    background-color: #C4E4ff;   \n",
    "    padding: 2px 25px;\n",
    "}\n",
    ".rendered_html pre {\n",
    "    background-color: #99c9ff;\n",
    "}\n",
    "div.code_cell .CodeMirror {\n",
    "    font-size: 2rem !important;\n",
    "    line-height: 2.4rem !important;\n",
    "}\n",
    ".rendered_html img, .rendered_html svg {\n",
    "    max-width: 100%;\n",
    "    height: auto;\n",
    "    float: center;\n",
    "}\n",
    "/* Gradient transparent - color - transparent */\n",
    "hr {\n",
    "    border: 0;\n",
    "    border-bottom: 1px dashed #ccc;\n",
    "}\n",
    ".emoticon{\n",
    "    font-size: 5rem;\n",
    "    line-height: 4.4rem;\n",
    "    text-align: center;\n",
    "    vertical-align: middle;\n",
    "}\n",
    "\n",
    "</style>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 语音识别\n",
    "\n",
    "语音识别的应用场景非常丰富。例如：\n",
    "\n",
    "* 语音输入：摆脱生僻字和拼音障碍，使用语音即时输入。甚至可以有方言，自动纠错、自动断句添加标点等辅助\n",
    "![](https://ai.bdstatic.com/file/EFD55AF95D98482BAB1C5E07013E6D8D)\n",
    "\n",
    "* 语音搜索：搜索内容直接以语音的方式输入，应用于网页搜索、车载搜索、手机搜索等各种搜索场景，解放双手让搜索更加高效，适用于视频网站、智能硬件、手机厂商等多个行业\n",
    "![](https://ai.bdstatic.com/file/CA0EF5EE32D44AF6B8716662D15570B9)\n",
    "\n",
    "* 语音指令：无需手动操作，可以通过语音直接对设备或者软件发布指令，控制操作，适用于智能硬件、车载系统、机器人、手机APP、游戏等多个领域\n",
    "![](https://ai.bdstatic.com/file/F73BE275D3D54035895C4EC560E58CAB)\n",
    "\n",
    "* 社交聊天：社交聊天时直接用语音输入的方式转成文字，让输入更加便捷；或者在收到语音消息不适合播放时可以转为文字进行查看，满足更多的聊天场景\n",
    "![](https://ai.bdstatic.com/file/BE9181FF4BD9420A866D1D7E2E32B5CB)\n",
    "\n",
    "* 游戏娱乐：游戏中聊天必不可少，双手无法打字，语音输入可以将语音聊天转为文字，让用户在操作的同时也可直观看到聊天内容，多样化满足用户聊天需求\n",
    "![](https://ai.bdstatic.com/file/78B0268E96354FE6ACA285107001B89B)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Azure语音识别API阅读\n",
    "\n",
    "* [Azure语音识别](https://azure.microsoft.com/zh-cn/services/cognitive-services/speech-to-text/#features)\n",
    "\n",
    "* 案例：google[语音助手敢和真人打电话！(演示+中文字幕)](http://e.nfu.edu.cn/pluginfile.php/4938/mod_folder/content/0/06_Google%202018%20%E9%80%86%E5%A4%A9%E9%BB%91%E7%A7%91%E6%8A%80%EF%BC%9A%E8%AF%AD%E9%9F%B3%E5%8A%A9%E6%89%8B%E6%95%A2%E5%92%8C%E7%9C%9F%E4%BA%BA%E6%89%93%E7%94%B5%E8%AF%9D%EF%BC%81%28%E6%BC%94%E7%A4%BA%2B%E4%B8%AD%E6%96%87%E5%AD%97%E5%B9%95%29-W0DcupvNv_U.mp4)\n",
    "\n",
    "* [Azure REST API](https://docs.microsoft.com/zh-cn/azure/cognitive-services/speech/getstarted/getstartedrest)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 实践百度语音识别API\n",
    "\n",
    "* [Baidu Speech](http://yuyin.baidu.com/)\n",
    "* [Baidu TTS](http://ai.baidu.com/tech/speech/tts)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### A-1 Baidu Speech ASR\n",
    "\n",
    "* 语音识别（（Automatic Speech Recognition））"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"access_token\":\"24.87c45e4678e3165898c619c3167436b1.2592000.1591434956.282335-15803531\",\"session_key\":\"9mzdA51v0yUCJxDCM1E\\/M7648m0jd\\/BlgOBYCSv3LKFUfvHVPLLD0+0KBPfHEAYp4M7NfHhs1WpDNmhrteqkTGiF9m6mXg==\",\"scope\":\"brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr audio_voice_assistant_get audio_tts_post public brain_all_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\\u5f00\\u653eScope vis-ocr_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 idl-video_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406\",\"refresh_token\":\"25.bf75c0ad74e0e8b0cc6ef22d2ef28130.315360000.1904202956.282335-15803531\",\"session_secret\":\"0b5804b71859cfaae371795a42940d0c\",\"expires_in\":2592000}\n",
      "\n",
      "{'access_token': '24.87c45e4678e3165898c619c3167436b1.2592000.1591434956.282335-15803531', 'session_key': '9mzdA51v0yUCJxDCM1E/M7648m0jd/BlgOBYCSv3LKFUfvHVPLLD0+0KBPfHEAYp4M7NfHhs1WpDNmhrteqkTGiF9m6mXg==', 'scope': 'brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr audio_voice_assistant_get audio_tts_post public brain_all_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理', 'refresh_token': '25.bf75c0ad74e0e8b0cc6ef22d2ef28130.315360000.1904202956.282335-15803531', 'session_secret': '0b5804b71859cfaae371795a42940d0c', 'expires_in': 2592000}\n",
      "SUCCESS WITH TOKEN: 24.87c45e4678e3165898c619c3167436b1.2592000.1591434956.282335-15803531 ; EXPIRES IN SECONDS: 2592000\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.87c45e4678e3165898c619c3167436b1.2592000.1591434956.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 25979}\n",
      "Request time cost 0.704811\n",
      "{\"corpus_no\":\"6824028535944215334\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"北京科技馆。\"],\"sn\":\"306765392711588842956\"}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# A-1\n",
    "\n",
    "import sys\n",
    "import json\n",
    "import time\n",
    "\n",
    "IS_PY3 = sys.version_info.major == 3\n",
    "\n",
    "if IS_PY3:\n",
    "    from urllib.request import urlopen\n",
    "    from urllib.request import Request\n",
    "    from urllib.error import URLError\n",
    "    from urllib.parse import urlencode\n",
    "\n",
    "    timer = time.perf_counter\n",
    "else:\n",
    "    import urllib2\n",
    "    from urllib2 import urlopen\n",
    "    from urllib2 import Request\n",
    "    from urllib2 import URLError\n",
    "    from urllib import urlencode\n",
    "\n",
    "    if sys.platform == \"win32\":\n",
    "        timer = time.clock\n",
    "    else:\n",
    "        # On most other platforms the best timer is time.time()\n",
    "        timer = time.time\n",
    "\n",
    "API_KEY = 'kVcnfD9iW2XVZSMaLMrtLYIz'\n",
    "SECRET_KEY = 'O9o1O213UgG5LFn0bDGNtoRN3VWl2du6'\n",
    "\n",
    "\n",
    "# 需要识别的文件\n",
    "AUDIO_FILE = './16k.m4a' # 只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "# 文件格式\n",
    "FORMAT = AUDIO_FILE[-3:];  # 文件后缀只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "\n",
    "CUID = '123456PYTHON';\n",
    "# 采样率\n",
    "RATE = 16000;  # 固定值\n",
    "\n",
    "# 普通版\n",
    "\n",
    "DEV_PID = 1537;  # 1537 表示识别普通话，使用输入法模型。根据文档填写PID，选择语言及识别模型\n",
    "ASR_URL = 'http://vop.baidu.com/server_api'\n",
    "SCOPE = 'audio_voice_assistant_get'  # 有此scope表示有asr能力，没有请在网页里勾选，非常旧的应用可能没有\n",
    "\n",
    "#测试自训练平台需要打开以下信息， 自训练平台模型上线后，您会看见 第二步：“”获取专属模型参数pid:8001，modelid:1234”，按照这个信息获取 dev_pid=8001，lm_id=1234\n",
    "# DEV_PID = 8001 ;   \n",
    "# LM_ID = 1234 ;\n",
    "\n",
    "# 极速版 打开注释的话请填写自己申请的appkey appSecret ，并在网页中开通极速版（开通后可能会收费）\n",
    "\n",
    "#DEV_PID = 80001\n",
    "#ASR_URL = 'http://vop.baidu.com/pro_api'\n",
    "#SCOPE = 'brain_enhanced_asr'  # 有此scope表示有asr能力，没有请在网页里开通极速版\n",
    "\n",
    "# 忽略scope检查，非常旧的应用可能没有\n",
    "# SCOPE = False\n",
    "\n",
    "\n",
    "# 极速版\n",
    "\n",
    "class DemoError(Exception):\n",
    "    pass\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN start \"\"\"\n",
    "\n",
    "TOKEN_URL = 'http://openapi.baidu.com/oauth/2.0/token'\n",
    "\n",
    "\n",
    "def fetch_token():\n",
    "    params = {'grant_type': 'client_credentials',\n",
    "              'client_id': API_KEY,\n",
    "              'client_secret': SECRET_KEY}\n",
    "    post_data = urlencode(params)\n",
    "    if (IS_PY3):\n",
    "        post_data = post_data.encode('utf-8')\n",
    "    req = Request(TOKEN_URL, post_data)\n",
    "    try:\n",
    "        f = urlopen(req)\n",
    "        result_str = f.read()\n",
    "    except URLError as err:\n",
    "        print('token http response http code : ' + str(err.code))\n",
    "        result_str = err.read()\n",
    "    if (IS_PY3):\n",
    "        result_str = result_str.decode()\n",
    "\n",
    "    print(result_str)\n",
    "    result = json.loads(result_str)\n",
    "    print(result)\n",
    "    if ('access_token' in result.keys() and 'scope' in result.keys()):\n",
    "        if SCOPE and (not SCOPE in result['scope'].split(' ')):  # SCOPE = False 忽略检查\n",
    "            raise DemoError('scope is not correct')\n",
    "        print('SUCCESS WITH TOKEN: %s ; EXPIRES IN SECONDS: %s' % (result['access_token'], result['expires_in']))\n",
    "        return result['access_token']\n",
    "    else:\n",
    "        raise DemoError('MAYBE API_KEY or SECRET_KEY not correct: access_token or scope not found in token response')\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN end \"\"\"\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    token = fetch_token()\n",
    "\n",
    "    \"\"\"\n",
    "    httpHandler = urllib2.HTTPHandler(debuglevel=1)\n",
    "    opener = urllib2.build_opener(httpHandler)\n",
    "    urllib2.install_opener(opener)\n",
    "    \"\"\"\n",
    "\n",
    "    speech_data = []\n",
    "    with open(AUDIO_FILE, 'rb') as speech_file:\n",
    "        speech_data = speech_file.read()\n",
    "    length = len(speech_data)\n",
    "    if length == 0:\n",
    "        raise DemoError('file %s length read 0 bytes' % AUDIO_FILE)\n",
    "\n",
    "    params = {'cuid': CUID, 'token': token, 'dev_pid': DEV_PID}\n",
    "    #测试自训练平台需要打开以下信息\n",
    "    #params = {'cuid': CUID, 'token': token, 'dev_pid': DEV_PID, 'lm_id' : LM_ID}\n",
    "    params_query = urlencode(params);\n",
    "\n",
    "    headers = {\n",
    "        'Content-Type': 'audio/' + FORMAT + '; rate=' + str(RATE),\n",
    "        'Content-Length': length\n",
    "    }\n",
    "\n",
    "    url = ASR_URL + \"?\" + params_query\n",
    "    print(\"url is\", url);\n",
    "    print(\"header is\", headers)\n",
    "    # print post_data\n",
    "    req = Request(ASR_URL + \"?\" + params_query, speech_data, headers)\n",
    "    try:\n",
    "        begin = timer()\n",
    "        f = urlopen(req)\n",
    "        result_str = f.read()\n",
    "        print(\"Request time cost %f\" % (timer() - begin))\n",
    "    except  URLError as err:\n",
    "        print('asr http response http code : ' + str(err.code))\n",
    "        result_str = err.read()\n",
    "\n",
    "    if (IS_PY3):\n",
    "        result_str = str(result_str, 'utf-8')\n",
    "    print(result_str)\n",
    "    with open(\"result.txt\", \"w\") as of:\n",
    "        of.write(result_str)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### A-2 Baidu TTS\n",
    "\n",
    "* 语音合成（Text-to-Speach）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "fetch token begin\n",
      "{\"access_token\":\"24.445b77171e4f7b941bab02aa8afac70d.2592000.1591436283.282335-10854623\",\"session_key\":\"9mzdDxA\\/tF57KfrioNFuCxfYjyWBxrPBMjRJxrsPJMeMWzxeAtkxUl20FGor7ZFgcwdQKWeovJwSzd3U3bFfHpAnFueMcw==\",\"scope\":\"brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr unit_\\u7406\\u89e3\\u4e0e\\u4ea4\\u4e92V2 public audio_voice_assistant_get audio_tts_post wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\\u5f00\\u653eScope vis-ocr_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 idl-video_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406\",\"refresh_token\":\"25.bf5e8125e485265a71b46c04a4f8d468.315360000.1904204283.282335-10854623\",\"session_secret\":\"267bbdced784ecedc35b465cd9626222\",\"expires_in\":2592000}\n",
      "\n",
      "{'access_token': '24.445b77171e4f7b941bab02aa8afac70d.2592000.1591436283.282335-10854623', 'session_key': '9mzdDxA/tF57KfrioNFuCxfYjyWBxrPBMjRJxrsPJMeMWzxeAtkxUl20FGor7ZFgcwdQKWeovJwSzd3U3bFfHpAnFueMcw==', 'scope': 'brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr unit_理解与交互V2 public audio_voice_assistant_get audio_tts_post wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理', 'refresh_token': '25.bf5e8125e485265a71b46c04a4f8d468.315360000.1904204283.282335-10854623', 'session_secret': '267bbdced784ecedc35b465cd9626222', 'expires_in': 2592000}\n",
      "SUCCESS WITH TOKEN: 24.445b77171e4f7b941bab02aa8afac70d.2592000.1591436283.282335-10854623 ; EXPIRES IN SECONDS: 2592000\n",
      "%E6%AC%A2%E8%BF%8E%E4%BD%BF%E7%94%A8%E7%99%BE%E5%BA%A6%E8%AF%AD%E9%9F%B3%E5%90%88%E6%88%90%E3%80%82\n",
      "test on Web Browserhttp://tsn.baidu.com/text2audio?tok=24.445b77171e4f7b941bab02aa8afac70d.2592000.1591436283.282335-10854623&tex=%25E6%25AC%25A2%25E8%25BF%258E%25E4%25BD%25BF%25E7%2594%25A8%25E7%2599%25BE%25E5%25BA%25A6%25E8%25AF%25AD%25E9%259F%25B3%25E5%2590%2588%25E6%2588%2590%25E3%2580%2582&per=4&spd=5&pit=5&vol=5&aue=3&cuid=123456PYTHON&lan=zh&ctp=1\n",
      "result saved as :result.mp3\n"
     ]
    }
   ],
   "source": [
    "# coding=utf-8\n",
    "import sys\n",
    "import json\n",
    "\n",
    "IS_PY3 = sys.version_info.major == 3\n",
    "if IS_PY3:\n",
    "    from urllib.request import urlopen\n",
    "    from urllib.request import Request\n",
    "    from urllib.error import URLError\n",
    "    from urllib.parse import urlencode\n",
    "    from urllib.parse import quote_plus\n",
    "else:\n",
    "    import urllib2\n",
    "    from urllib import quote_plus\n",
    "    from urllib2 import urlopen\n",
    "    from urllib2 import Request\n",
    "    from urllib2 import URLError\n",
    "    from urllib import urlencode\n",
    "\n",
    "API_KEY = '4E1BG9lTnlSeIf1NQFlrSq6h'\n",
    "SECRET_KEY = '544ca4657ba8002e3dea3ac2f5fdd241'\n",
    "\n",
    "TEXT = \"欢迎使用百度语音合成。\"\n",
    "\n",
    "# 发音人选择, 基础音库：0为度小美，1为度小宇，3为度逍遥，4为度丫丫，\n",
    "# 精品音库：5为度小娇，103为度米朵，106为度博文，110为度小童，111为度小萌，默认为度小美 \n",
    "PER = 4\n",
    "# 语速，取值0-15，默认为5中语速\n",
    "SPD = 5\n",
    "# 音调，取值0-15，默认为5中语调\n",
    "PIT = 5\n",
    "# 音量，取值0-9，默认为5中音量\n",
    "VOL = 5\n",
    "# 下载的文件格式, 3：mp3(default) 4： pcm-16k 5： pcm-8k 6. wav\n",
    "AUE = 3\n",
    "\n",
    "FORMATS = {3: \"mp3\", 4: \"pcm\", 5: \"pcm\", 6: \"wav\"}\n",
    "FORMAT = FORMATS[AUE]\n",
    "\n",
    "CUID = \"123456PYTHON\"\n",
    "\n",
    "TTS_URL = 'http://tsn.baidu.com/text2audio'\n",
    "\n",
    "\n",
    "class DemoError(Exception):\n",
    "    pass\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN start \"\"\"\n",
    "\n",
    "TOKEN_URL = 'http://openapi.baidu.com/oauth/2.0/token'\n",
    "SCOPE = 'audio_tts_post'  # 有此scope表示有tts能力，没有请在网页里勾选\n",
    "\n",
    "\n",
    "def fetch_token():\n",
    "    print(\"fetch token begin\")\n",
    "    params = {'grant_type': 'client_credentials',\n",
    "              'client_id': API_KEY,\n",
    "              'client_secret': SECRET_KEY}\n",
    "    post_data = urlencode(params)\n",
    "    if (IS_PY3):\n",
    "        post_data = post_data.encode('utf-8')\n",
    "    req = Request(TOKEN_URL, post_data)\n",
    "    try:\n",
    "        f = urlopen(req, timeout=5)\n",
    "        result_str = f.read()\n",
    "    except URLError as err:\n",
    "        print('token http response http code : ' + str(err.code))\n",
    "        result_str = err.read()\n",
    "    if (IS_PY3):\n",
    "        result_str = result_str.decode()\n",
    "\n",
    "    print(result_str)\n",
    "    result = json.loads(result_str)\n",
    "    print(result)\n",
    "    if ('access_token' in result.keys() and 'scope' in result.keys()):\n",
    "        if not SCOPE in result['scope'].split(' '):\n",
    "            raise DemoError('scope is not correct')\n",
    "        print('SUCCESS WITH TOKEN: %s ; EXPIRES IN SECONDS: %s' % (result['access_token'], result['expires_in']))\n",
    "        return result['access_token']\n",
    "    else:\n",
    "        raise DemoError('MAYBE API_KEY or SECRET_KEY not correct: access_token or scope not found in token response')\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN end \"\"\"\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    token = fetch_token()\n",
    "    tex = quote_plus(TEXT)  # 此处TEXT需要两次urlencode\n",
    "    print(tex)\n",
    "    params = {'tok': token, 'tex': tex, 'per': PER, 'spd': SPD, 'pit': PIT, 'vol': VOL, 'aue': AUE, 'cuid': CUID,\n",
    "              'lan': 'zh', 'ctp': 1}  # lan ctp 固定参数\n",
    "\n",
    "    data = urlencode(params)\n",
    "    print('test on Web Browser' + TTS_URL + '?' + data)\n",
    "\n",
    "    req = Request(TTS_URL, data.encode('utf-8'))\n",
    "    has_error = False\n",
    "    try:\n",
    "        f = urlopen(req)\n",
    "        result_str = f.read()\n",
    "\n",
    "        headers = dict((name.lower(), value) for name, value in f.headers.items())\n",
    "\n",
    "        has_error = ('content-type' not in headers.keys() or headers['content-type'].find('audio/') < 0)\n",
    "    except  URLError as err:\n",
    "        print('asr http response http code : ' + str(err.code))\n",
    "        result_str = err.read()\n",
    "        has_error = True\n",
    "\n",
    "    save_file = \"error.txt\" if has_error else 'result.' + FORMAT\n",
    "    with open(save_file, 'wb') as of:\n",
    "        of.write(result_str)\n",
    "\n",
    "    if has_error:\n",
    "        if (IS_PY3):\n",
    "            result_str = str(result_str, 'utf-8')\n",
    "        print(\"tts api  error:\" + result_str)\n",
    "\n",
    "    print(\"result saved as :\" + save_file)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 实践：视频如何转文本\n",
    "\n",
    "\n",
    "* 思考：如何将video转换成text？具体步骤？API语音合成应该是第几步？\n",
    "\n",
    "* 思考结果填写：___\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## B-1 moviepy 视频转换音频\n",
    "\n",
    "* [moviepy文档](https://zulko.github.io/moviepy/ref/AudioClip.html?highlight=subclip#moviepy.audio.AudioClip.CompositeAudioClip.subclip)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   0%|          | 54/74893 [00:00<02:23, 521.61it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in theaudio.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                       "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r"
     ]
    }
   ],
   "source": [
    "# B-1\n",
    "import moviepy.editor as mp\n",
    "clip = mp.VideoFileClip(\"04301846.mp4\")\n",
    "clip.audio.write_audiofile(\"theaudio.mp3\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## B-2 计算音频时间 duration"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3396.5"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# B-2 clip.duration计算video时间(秒)\n",
    "clip.duration"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 音频剪辑（拆分）\n",
    "\n",
    "* 请阅读百度API文档，回答语音识别API的最大长度？\n",
    "\n",
    "* 根据API的实际能力将音频拆分，并转换对应可使用的格式\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### B-3 尝试剪辑一段？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   4%|▍         | 50/1301 [00:00<00:02, 490.56it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in theaudio_split_test.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     "
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r"
     ]
    }
   ],
   "source": [
    "# B-3\n",
    "\n",
    "clip = mp.VideoFileClip(\"04301846.mp4\")\n",
    "newclip = clip.subclip(t_start=0,t_end=59)\n",
    "newclip.audio.write_audiofile('theaudio_split_test.mp3')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### B-4批量剪辑整段音频"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   4%|▍         | 54/1301 [00:00<00:02, 520.51it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_0.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 294.95it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_60.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 272.59it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_120.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 261.64it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_180.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 282.39it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_240.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 286.42it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_300.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 304.52it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_360.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 279.66it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_420.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "\r",
      "chunk:   0%|          | 0/1301 [00:00<?, ?it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_480.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 308.72it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_540.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 283.43it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_600.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 272.16it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_660.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 281.09it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_720.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 285.87it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_780.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 270.75it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_840.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 285.27it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_900.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 288.24it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_960.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 290.65it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1020.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 298.79it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1080.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 268.16it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1140.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 282.11it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1200.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 273.75it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1260.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 284.30it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1320.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 287.96it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1380.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:05, 238.43it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1440.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 274.32it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1500.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 269.51it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1560.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 295.16it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1620.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 292.12it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1680.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 307.91it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1740.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 286.15it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1800.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 292.97it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1860.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 289.70it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1920.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 297.51it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_1980.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 311.67it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2040.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 273.22it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2100.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 302.57it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2160.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 296.79it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2220.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 261.04it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2280.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 272.33it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2340.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:05, 251.05it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2400.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 256.55it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2460.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 294.68it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2520.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 267.45it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2580.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 292.89it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2640.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 279.84it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2700.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 287.60it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2760.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 295.52it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2820.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 293.89it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2880.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 289.79it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_2940.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:05, 248.08it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3000.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 287.25it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3060.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 291.95it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3120.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 284.63it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3180.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 291.36it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3240.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 282.80it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3300.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "                                                                     \r"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Done.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:   3%|▎         | 38/1301 [00:00<00:04, 253.55it/s, now=None]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "MoviePy - Writing audio in ../_week08_/audio/theaudio_3360.mp3\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "chunk:  58%|█████▊    | 758/1301 [00:01<00:01, 470.92it/s, now=None]"
     ]
    },
    {
     "ename": "OSError",
     "evalue": "Error in file 04301846.mp4, Accessing time t=3396.51-3396.55 seconds, with clip duration=3396 seconds, ",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mOSError\u001b[0m                                   Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-9-26b65f805f8f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0mclip\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mVideoFileClip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"04301846.mp4\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0mnewclip\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclip\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msubclip\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt_start\u001b[0m \u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m,\u001b[0m\u001b[0mt_end\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m59\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m     \u001b[0mnewclip\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maudio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite_audiofile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\"theaudio_\"\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\".mp3\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      7\u001b[0m     \u001b[0mi\u001b[0m \u001b[0;34m+=\u001b[0m\u001b[0;36m60\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      8\u001b[0m \u001b[0;31m#     print(newclip.duration)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<decorator-gen-169>\u001b[0m in \u001b[0;36mwrite_audiofile\u001b[0;34m(self, filename, fps, nbytes, buffersize, codec, bitrate, ffmpeg_params, write_logfile, verbose, logger)\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/decorators.py\u001b[0m in \u001b[0;36mrequires_duration\u001b[0;34m(f, clip, *a, **k)\u001b[0m\n\u001b[1;32m     52\u001b[0m         \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Attribute 'duration' not set\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     53\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 54\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclip\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     55\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/AudioClip.py\u001b[0m in \u001b[0;36mwrite_audiofile\u001b[0;34m(self, filename, fps, nbytes, buffersize, codec, bitrate, ffmpeg_params, write_logfile, verbose, logger)\u001b[0m\n\u001b[1;32m    208\u001b[0m                                  \u001b[0mwrite_logfile\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mwrite_logfile\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mverbose\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    209\u001b[0m                                  \u001b[0mffmpeg_params\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mffmpeg_params\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 210\u001b[0;31m                                  logger=logger)\n\u001b[0m\u001b[1;32m    211\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    212\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<decorator-gen-133>\u001b[0m in \u001b[0;36mffmpeg_audiowrite\u001b[0;34m(clip, filename, fps, nbytes, buffersize, codec, bitrate, write_logfile, verbose, ffmpeg_params, logger)\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/decorators.py\u001b[0m in \u001b[0;36mrequires_duration\u001b[0;34m(f, clip, *a, **k)\u001b[0m\n\u001b[1;32m     52\u001b[0m         \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Attribute 'duration' not set\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     53\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 54\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclip\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     55\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/io/ffmpeg_audiowriter.py\u001b[0m in \u001b[0;36mffmpeg_audiowrite\u001b[0;34m(clip, filename, fps, nbytes, buffersize, codec, bitrate, write_logfile, verbose, ffmpeg_params, logger)\u001b[0m\n\u001b[1;32m    167\u001b[0m                                   \u001b[0mquantize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    168\u001b[0m                                   \u001b[0mnbytes\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mnbytes\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfps\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mfps\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 169\u001b[0;31m                                   logger=logger):\n\u001b[0m\u001b[1;32m    170\u001b[0m         \u001b[0mwriter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mwrite_frames\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mchunk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    171\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/AudioClip.py\u001b[0m in \u001b[0;36miter_chunks\u001b[0;34m(self, chunksize, chunk_duration, fps, quantize, nbytes, logger)\u001b[0m\n\u001b[1;32m     84\u001b[0m             \u001b[0mtt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m1.0\u001b[0m\u001b[0;34m/\u001b[0m\u001b[0mfps\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpospos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpospos\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     85\u001b[0m             yield self.to_soundarray(tt, nbytes=nbytes, quantize=quantize,\n\u001b[0;32m---> 86\u001b[0;31m                                         fps=fps, buffersize=chunksize)\n\u001b[0m\u001b[1;32m     87\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     88\u001b[0m     \u001b[0;34m@\u001b[0m\u001b[0mrequires_duration\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<decorator-gen-168>\u001b[0m in \u001b[0;36mto_soundarray\u001b[0;34m(self, tt, fps, quantize, nbytes, buffersize)\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/decorators.py\u001b[0m in \u001b[0;36mrequires_duration\u001b[0;34m(f, clip, *a, **k)\u001b[0m\n\u001b[1;32m     52\u001b[0m         \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Attribute 'duration' not set\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     53\u001b[0m     \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 54\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mclip\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     55\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     56\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/AudioClip.py\u001b[0m in \u001b[0;36mto_soundarray\u001b[0;34m(self, tt, fps, quantize, nbytes, buffersize)\u001b[0m\n\u001b[1;32m    125\u001b[0m         \u001b[0;31m#print tt.max() - tt.min(), tt.min(), tt.max()\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    126\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 127\u001b[0;31m         \u001b[0msnd_array\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_frame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    128\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    129\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mquantize\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<decorator-gen-135>\u001b[0m in \u001b[0;36mget_frame\u001b[0;34m(self, t)\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(f, *a, **kw)\u001b[0m\n\u001b[1;32m     87\u001b[0m         new_kw = {k: fun(v) if k in varnames else v\n\u001b[1;32m     88\u001b[0m                  for (k,v) in kw.items()}\n\u001b[0;32m---> 89\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mnew_a\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mnew_kw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     90\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0mdecorator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecorator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwrapper\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     91\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/Clip.py\u001b[0m in \u001b[0;36mget_frame\u001b[0;34m(self, t)\u001b[0m\n\u001b[1;32m     91\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mframe\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     92\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 93\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_frame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     94\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     95\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mfl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfun\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mapply_to\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeep_duration\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/Clip.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(t)\u001b[0m\n\u001b[1;32m    134\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    135\u001b[0m         \u001b[0;31m#mf = copy(self.make_frame)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 136\u001b[0;31m         \u001b[0mnewclip\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset_make_frame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;32mlambda\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mfun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_frame\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    137\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    138\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mkeep_duration\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/Clip.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(gf, t)\u001b[0m\n\u001b[1;32m    185\u001b[0m             \u001b[0mapply_to\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    186\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 187\u001b[0;31m         return self.fl(lambda gf, t: gf(t_func(t)), apply_to,\n\u001b[0m\u001b[1;32m    188\u001b[0m                        keep_duration=keep_duration)\n\u001b[1;32m    189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m<decorator-gen-135>\u001b[0m in \u001b[0;36mget_frame\u001b[0;34m(self, t)\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/decorators.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(f, *a, **kw)\u001b[0m\n\u001b[1;32m     87\u001b[0m         new_kw = {k: fun(v) if k in varnames else v\n\u001b[1;32m     88\u001b[0m                  for (k,v) in kw.items()}\n\u001b[0;32m---> 89\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mnew_a\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mnew_kw\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     90\u001b[0m     \u001b[0;32mreturn\u001b[0m \u001b[0mdecorator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdecorator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwrapper\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     91\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/Clip.py\u001b[0m in \u001b[0;36mget_frame\u001b[0;34m(self, t)\u001b[0m\n\u001b[1;32m     91\u001b[0m                 \u001b[0;32mreturn\u001b[0m \u001b[0mframe\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     92\u001b[0m         \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 93\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_frame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     94\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     95\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mfl\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfun\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mapply_to\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeep_duration\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/io/AudioFileClip.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(t)\u001b[0m\n\u001b[1;32m     75\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuffersize\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuffersize\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     76\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 77\u001b[0;31m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmake_frame\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_frame\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     78\u001b[0m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnchannels\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreader\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnchannels\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     79\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/moviepy/audio/io/readers.py\u001b[0m in \u001b[0;36mget_frame\u001b[0;34m(self, tt)\u001b[0m\n\u001b[1;32m    169\u001b[0m                 raise IOError(\"Error in file %s, \"%(self.filename)+\n\u001b[1;32m    170\u001b[0m                        \u001b[0;34m\"Accessing time t=%.02f-%.02f seconds, \"\u001b[0m\u001b[0;34m%\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 171\u001b[0;31m                        \"with clip duration=%d seconds, \"%self.duration)\n\u001b[0m\u001b[1;32m    172\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    173\u001b[0m             \u001b[0;31m# The np.round in the next line is super-important.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mOSError\u001b[0m: Error in file 04301846.mp4, Accessing time t=3396.51-3396.55 seconds, with clip duration=3396 seconds, "
     ]
    }
   ],
   "source": [
    "path = '../_week08_/audio/'\n",
    "i = 0\n",
    "while True:\n",
    "    clip = mp.VideoFileClip(\"04301846.mp4\")\n",
    "    newclip = clip.subclip(t_start =(i) ,t_end = (i+59))\n",
    "    newclip.audio.write_audiofile(path+\"theaudio_\"+str(i)+\".mp3\")\n",
    "    i +=60\n",
    "#     print(newclip.duration)\n",
    "    if i > clip.duration:  \n",
    "        break "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## B-5 mp3转换为API识别的格式\n",
    "\n",
    "* (如百度API语音识别：pcm/wav/amr/m4a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "theaudio_1620.m4a\n",
      "theaudio_3180.m4a\n",
      "theaudio_1740.m4a\n",
      "theaudio_2880.m4a\n",
      "theaudio_2100.m4a\n",
      "theaudio_660.m4a\n",
      "theaudio_1140.m4a\n",
      "theaudio_300.m4a\n",
      "theaudio_1020.m4a\n",
      "theaudio_0.m4a\n",
      "theaudio_1380.m4a\n",
      "theaudio_2460.m4a\n",
      "theaudio_1800.m4a\n",
      "theaudio_840.m4a\n",
      "theaudio_2700.m4a\n",
      "theaudio_1680.m4a\n",
      "theaudio_2160.m4a\n",
      "theaudio_3120.m4a\n",
      "theaudio_2940.m4a\n",
      "theaudio_1440.m4a\n",
      "theaudio_2820.m4a\n",
      "theaudio_600.m4a\n",
      "theaudio_3240.m4a\n",
      "theaudio_2760.m4a\n",
      "theaudio_1080.m4a\n",
      "theaudio_1320.m4a\n",
      "theaudio_360.m4a\n",
      "theaudio_2400.m4a\n",
      "theaudio_1860.m4a\n",
      "theaudio_1500.m4a\n",
      "theaudio_3060.m4a\n",
      "theaudio_2340.m4a\n",
      "theaudio_3300.m4a\n",
      "theaudio_780.m4a\n",
      "theaudio_2220.m4a\n",
      "theaudio_540.m4a\n",
      "theaudio_420.m4a\n",
      "theaudio_1260.m4a\n",
      "theaudio_2580.m4a\n",
      "theaudio_960.m4a\n",
      "theaudio_60.m4a\n",
      "theaudio_180.m4a\n",
      "theaudio_1920.m4a\n",
      "theaudio_3360.m4a\n",
      "theaudio_1560.m4a\n",
      "theaudio_2280.m4a\n",
      "theaudio_720.m4a\n",
      "theaudio_2040.m4a\n",
      "theaudio_480.m4a\n",
      "theaudio_3000.m4a\n",
      "theaudio_2520.m4a\n",
      "theaudio_240.m4a\n",
      "theaudio_120.m4a\n",
      "theaudio_1200.m4a\n",
      "theaudio_1980.m4a\n",
      "theaudio_900.m4a\n",
      "theaudio_2640.m4a\n"
     ]
    }
   ],
   "source": [
    "# B-5\n",
    "import os\n",
    "movie_name = os.listdir('../_week08_/audio/')\n",
    "for temp in movie_name:\n",
    "    print(temp.split('.')[0]+'.m4a')\n",
    "    new_name = temp.split('.')[0]+'.m4a'\n",
    "    os.rename('../_week08_/audio/'+temp,'../_week08_/audio/'+new_name)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 调用百度API :实现video—text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"access_token\":\"24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531\",\"session_key\":\"9mzdCXceMZ02GjXWJxEU7Mgg8suYg6Q90Gq6tX5V06EgKvw5T9Acxqulj0bSyWE+5xeKyPE3cB0lEIcf5kaKKsHrVvljQw==\",\"scope\":\"brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr audio_voice_assistant_get audio_tts_post public brain_all_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\\u6743\\u9650 vis-classify_flower lpq_\\u5f00\\u653e cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_\\u5f00\\u653eScope vis-ocr_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406 idl-video_\\u865a\\u62df\\u4eba\\u7269\\u52a9\\u7406\",\"refresh_token\":\"25.88f42106a3b91174f66f5f0587c9004d.315360000.1904204084.282335-15803531\",\"session_secret\":\"669f8155b42f2228a53abb1a4480c153\",\"expires_in\":2592000}\n",
      "\n",
      "{'access_token': '24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531', 'session_key': '9mzdCXceMZ02GjXWJxEU7Mgg8suYg6Q90Gq6tX5V06EgKvw5T9Acxqulj0bSyWE+5xeKyPE3cB0lEIcf5kaKKsHrVvljQw==', 'scope': 'brain_speech_realtime vis-faceverify_FACE_Police brain_enhanced_asr audio_voice_assistant_get audio_tts_post public brain_all_scope wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test权限 vis-classify_flower lpq_开放 cop_helloScope ApsMis_fangdi_permission smartapp_snsapi_base iop_autocar oauth_tp_app smartapp_smart_game_openapi oauth_sessionkey smartapp_swanid_verify smartapp_opensource_openapi smartapp_opensource_recapi fake_face_detect_开放Scope vis-ocr_虚拟人物助理 idl-video_虚拟人物助理', 'refresh_token': '25.88f42106a3b91174f66f5f0587c9004d.315360000.1904204084.282335-15803531', 'session_secret': '669f8155b42f2228a53abb1a4480c153', 'expires_in': 2592000}\n",
      "SUCCESS WITH TOKEN: 24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531 ; EXPIRES IN SECONDS: 2592000\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 4.841897\n",
      "{\"corpus_no\":\"6824033393434789141\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"现象好，那我们这一边这边一个例子就是很多例子我就不讲了，什么电影之类的，你们自己可以随便看看看，然后这边也只是给你们介绍了什么叫基于内容跟基于协同的话，这个礼拜就讲了，你们可以再读一次强化你们的印象哈，我就不多说，但在个性化推荐也是然后你们自己看哦讲蓝天依旧是你就是这么多不同行业哦我们产品经理不是要交我在上课的不同行业跟不同产业的这个这个差别那这一些行业呢他在这一边就是给你列举的推荐人干嘛啊第一的对吧电商有这些内容啊？给各位稍微就是快速看一下第三排第一然后呢又对了，没有电影跟视频网站这是不是新媒体这他妈的四吗那你再跟我讲说我们网络新媒体，我都爱上网络没有交接。\"],\"sn\":\"52497319941588844087\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 4.020055\n",
      "{\"corpus_no\":\"6824033414976494697\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"但信息的人了解的话，这些东西就是有数据库，它怎么来的？然后这些东西怎么做？特征这个项链啊，所以说这张图很有用的部分是如果说你有嗯，基本的这个营销人员跟这个呃，系统系统人员的话，你们就可以把这个架构给做出来了，那我们就讲完了啊梅基本上我要讲的东西也在这一小时之内都讲完了然后就是比我预期的超了十分钟啊，希望这些内容对各位有帮助然后呢，该考考考考考考考，然后机考可能嗯，就是这个嗯嗯叫谁啊徐老师还在优化啊，因为我们尽量不想给各位就是嗯老学生考过的高考我们要给主要是出一些新的题目啊，一些新闻然后呢所以呢，今天都是说考不了的话没关系啊，我们就是。\"],\"sn\":\"582789484521588844091\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.179374\n",
      "{\"corpus_no\":\"6824033427791290180\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"我们这一些内容，你可以稍微看一下的音乐推荐的这个特点，这个算是嗯刚刚讲的就是推进系统大会也是a实验的啊，很有名的，那他们这边的行业人员啊，潘多拉是一个这个一个一个大数据公司啊，还有交互设计公司啊，他们就是这个行业的，这些内容对不对那这个内容重不重要？你能不能变成你产品设计的一个重要的来源是吧？那这个东西技术吗这东西技术嘛，这东西就是彩页信息啊是吧啊所以呢，这个这些啊，这边都有写了好再来所以说你看到了哈，这边已经有不同的行业和不同的物品的差别，然后再还是什么社交网络是吧你刚刚看到这些媒体的这个平台还有社交网络包含信息流对绘画？推荐一个不是在做推荐系统，哪一个不是？\"],\"sn\":\"664291737651588844095\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.682971\n",
      "{\"corpus_no\":\"6824033440728528658\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"就是我我我这边没什么好解释，就是你们在就是就是求我或者交配，但是交配还是交配，还是求我的时候基本上都会有这些所谓隐形跟你跟凡人凡心这些行为，然后你们都会在累积一些判别系统是吧，他到底跟你就是砸个眼，然后拍着你的肩膀或者揍你一圈到底那是什么意思？那基本上这个对于用户的这种猥琐的行为，他这些行为累积起来到底意味着什么，这就是写信给你性的差别好再来这边就有写哈哈请这个东西真的还蛮好的内容哈就是呃呃，你那边看对营销科技那些鸡汤文还不如看这种非常具有分析性，然后具有这个产业就是就是浓缩价值的内容哈，你们就要思考下一。\"],\"sn\":\"855362859201588844098\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 5.890770\n",
      "{\"corpus_no\":\"6824033470742800548\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"数据，然后输出能干嘛？这个楚楚的东西，我们可以拿来就是调整我们的产品设计啊，这一些就是你呃用户研究设计的一个重要来源啊，我感觉好就是app你们常见的这些交互产品，不管是什么的？那基本上很多的所谓的大数据跟智能的内容大概推荐系统可以上到四层到五层啊那所以呢，你对于这一些评测指标，特别是跟用户相关的评测指标，如何能辅助你的业务，这是非常非常重要的啊，这也是为什么我我会拿着一个比较技术的书啊，挑出具有用户市场营销意义的内容，给各位介绍，不然你可以问问自己啊！\"],\"sn\":\"326407423751588844104\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 4.068904\n",
      "{\"corpus_no\":\"6824033483444910263\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"转发或只搞数据啊，最好是两种你都未领的业务的问题，你的这个业务的问题啊，业务的问题啊，特别是这个哈，你可以去看我数据不一定要完美，6十7十%分就好，算法也是哦，你也知道就是一个简单的逻辑就是从百分之70到100%真的会很累，可是百分之40到60%不难，真的不难那所以呢你取取取我数据要100分算法零分或者数据零分算法100分，不如你数据跟算法都做到60分啊，这是标准的，这个行业的基本的经验法则好，请各位就是要把这个重要的内容稍微记一下，好在。\"],\"sn\":\"4846336681588844108\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.602934\n",
      "{\"corpus_no\":\"6824033500681991215\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"用户界面的设计及产品设计的问题，然后这个东西作出做出来能干嘛呢？收集大数据，作出智能产品，ok好，那这样子你就搞定了啊，然后这个4.3这个部分呢，就算了哈就跳过当做没看到哈，然后呢，这个4.4给用户推荐票去就是我今天做这些活之后是不是要给用户作业推荐？这就是第二个延伸的交互产品啊，所以说4.244点4.4点4.4你在做交互设计跟产品设计的时候就要考量到就算你是ai小白啊，可是你已经在这门课本来就不应该是li小白哈可是就算你是真的这一门课学的非常着你，你api都都都烂掉了然后拍摄也烂烂的，可能至少。\"],\"sn\":\"346711118711588844112\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.174278\n",
      "{\"corpus_no\":\"6824033513717632001\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"吧，这一边我是我个人是上过啊，可是我并没有要强加说挨户我们网络新媒体专业，大家都来学代码跟演算法，我并没有这样要求，但是呢，我们就要就事论事，现在的行业，如果你随便看一下猎聘的这些内容，日本的产品经理或者运营人员需不需要知道这些数据，然后需不需要知道这些数据会不会拿来作为推荐系统的交互界面的内容，如果答案是的话，你就算推荐系统不需要知道背后的演算法跟数学，但是你需要知道这个跟用户行为跟推荐系统做出来的前端跟交互界面的官。\"],\"sn\":\"777435774371588844115\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.363599\n",
      "{\"corpus_no\":\"6824033526409240732\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"划重点啊，你一定要知道一些事情哈，这一个我们先从简单的开始做啊，标签系统的推荐问题呢，你这边就有很有趣的这个三个问题啊，为什么如何打什么样认为这个数据问题还是推人工智能问题都不是对不对？这是交互问题，他们现在可以做笔记，这一些内容，这个标签系统本本本本上就是一个交互，加上信息系统，这东西你们太熟悉，不过对不对我今天比如说上一个无无聊的知乎网站啊？比如说我上一个cp本人，他的网站我知道，给各位随便弄一下啊，是一个门缝，他的比较翻译一点吧，我们看。\"],\"sn\":\"976322652361588844118\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.415850\n",
      "{\"corpus_no\":\"6824033535029357524\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"大家听得到吗？我确定你们这一个界面，有没有听到你们的声音啊？你们先回一下，然后我把这个这一个就是输的这个啊，就是你叫什么摘要？嗯，就是就是它并不是全部都给你们啊，就是给你们就是一些基本的内容，然后这本书的设计基本上是有代码的，然后我基本上我今天介绍的内容基本上不是代码的部分，然后就是然后你会知道你会感觉到我我今天带各位念这一本书的目标不是要炫耀我多懂这些内容，而是我们要反过来从这个产品经理跟就是关心用。\"],\"sn\":\"25796086101588844120\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Request time cost 2.779621\n",
      "{\"corpus_no\":\"6824033547916084920\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"他是用这个所谓的用户研究的部分啊，所谓的这个ab测试和整合之类的，那这个部分呢？就给各位讲一下这个什么叫做评测指标啊，这个评测指标呢，有技术指标也有所有的业务指标及业务指标，当然就是所谓的用户使用数据好，那我们来试试看到底什么东西叫做呃，这个推荐系统啊，你还记得它的前提是信息快发走向信息过载啊，太多了，要过滤啊，这个东西就是跳过我们不用细讲了哈，然后呢？这一边有一个蛮重要的理论啊，我在1918级跟一六级的这个科技也就是第一门课这个啊，互联网就是我科技与写作的课都有交啊，可是我现在因为嗯，因为几个老师接近。\"],\"sn\":\"788769438961588844122\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.170312\n",
      "{\"corpus_no\":\"6824033560869393274\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"率的意思是我在这个世界上有这么多的网页，他给我这么多的推荐，他到底占了多少，在他的这个里面，他有没有落掉东西啊？所以说这个是准不准？有没有落东西？就这样子，哈哈，没有太复杂，这是非常直观的两个指标和覆盖律师，另外一个蛮重要指标，这个是跟常委有关系的话，这个到底说到底，说到底，因为常委就是非常细细小的，你要找到有时候很难找的啊，怕不是流行的东西，但这边有个覆盖率，这边稍微难一点，我就不是说了哈，这个基尼系数也也不用他讲太多啊，好，那我就多样性哦，这个太直观了，我就不解释了哈，这个这个数学是信息理论，这个汤的理论呃呃。\"],\"sn\":\"42998667931588844125\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.823816\n",
      "{\"corpus_no\":\"6824033573653711696\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"好然后呢？这一边也有出现所谓的apipipipipipi干嘛呢？就是如果你用的话，而且不止这个，诶诶诶诶，不对不对不对不对，他是不是把它平台经济话他给这些网站去做这个性化推荐啊？那就是平台经济，然后这就是这就是所谓的这个平台开放策略，哈哈再来哦个性化阅读就就就就大家都不读书就算了哈age位置啊poi对不对啊poi？个性化邮件大家都不看邮件啊跳过广告啊，这边我们稍微停一下啊，我们讲了一堆哈，你自己问自己是这个事情我们网线专业或全中国的网线专业有多少的广告老师在加广告，你可以问这件事情有多少的老师可以教市场？\"],\"sn\":\"176209950741588844128\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.804969\n",
      "{\"corpus_no\":\"6824033586654043696\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"笔记然后把它变成你作为api的这个舅舅智能切入的产品经理或者交互设计师，这样培养的方式把我今天这边的主要的重点稍微用你的话给记一下啊，这个东西呢，可能对于你考考试考过了，嘟嘟嘟以后来讲可能你就业啊，或者是不管是就业和考研，我刚刚讲的那些任务呢，可能比你等一下机考啊，打那几分更为重要，好好好，我们现在就来试试看，就是把这本书稍微呃，就是总结式的给各位介绍一下啊，好，我们从目录开始好，你看到这边第一第二第三节，第四章第四张哈，基本上我只要跟你们稍微提一下，你会发现。\"],\"sn\":\"39091792591588844132\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.186754\n",
      "{\"corpus_no\":\"6824033599573215951\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"没有，就是商家不诚实的部分很重要啊，实施性，我们上次讲过健壮性呢，这个是比较也算法的啊，还有这个反作弊的问题啊，这个东西呢，都是怕数据有人想大作弊啊，所以呢，这个东西就是借记得哈，所有的健壮性就是基本上就是防作弊啊，然后再来就是没了哈，这边有个总结哈，请各位稍微记一下啊，因为呢，这边的好处就是你至少不管是做业务数据，你先做运营的，你竟然做用户体验或者用户设计或者用户研究的啊，这一边都是重要的指标差别那你不同的研究方法啊，不同的实验方法，他的这个指标能不能处理你的问题是完全不一样的啊？所以比如说如果说你想要真你发现你的推荐系统经。\"],\"sn\":\"286489196491588844134\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.761481\n",
      "{\"corpus_no\":\"6824033612460407992\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"啊再思考一下思考一下电影跟视频网站，让他核心价值，它的核心平台价值是不是用户数据跟推荐系统问问是不是好再来？我们再来往下走，这个个性化音乐电台那你不要讲你们往易于那里有的没的，甚至这个抖音是不是都是这样好？那你就问一个问题，抖音跟之前的音乐平台跟音乐电台跟音乐媒体到底有什么不同？扣掉推荐系统，跟用户交互数据是不是一点又一点不同都没有我敢跟你这样说，是不是是的话？你就会知道说这一边就是全中国网新专业，没有给你好好系统交的部分是吧好的。\"],\"sn\":\"499718836601588844137\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.937618\n",
      "{\"corpus_no\":\"6824033621065635040\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"到底中国的这些网线专业或者加上的老师有多少人可以跟你这样子跨领域讲清楚这件事情啊？好，那我们就来看这个实验的部分，这是比较啊，就是需要前端工程师的人做的啊，那用户调研呢？特别欣赏调查就还好，只要是在线实验啊，基本上都要跟前端工程师合作，他们基本上就是在代码跟交互的交互设计人员调整做一些不同的小小的坑，那些小小的小坑就会留下不同的数据，然后呢，就可以给你做推荐系统的实验啊那这些东西呢？这边有一个这个离线跟这个上线的实验的优缺点，基本上这边的内容呢你一样。\"],\"sn\":\"425596604461588844140\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 7.983248\n",
      "{\"corpus_no\":\"6824033655506521656\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"要牵啊个人个个个人数据啊，这边全部都是大数据的这些内容来源呢啊，我这就不细讲了哈，这边就有这些呃用户的特征这个种类啊，这边稍微大家记一下页面哈就是啊，这一个用户跟物品的这个飞机系统这个部分啊，因为这东西就等于是一个重要的内容，你可以以以后做这些东西的价格的时候可以帮助你系统性的思考，不会改掉一些想法，然后我们网线专业经验的这个论文呢，我知道学生就有用这个主题模型或者话题模型做的这个这个数据科学项目啊，就是理财跟那个如家宴啊我们都有这些内容哈哈这些啊，这些啊都是啊推荐系统的一个潜在的这个演算法的这个这个提供的部分啊那这个架构图呢就随便看看就好了哈这个内容呢基本上是信息架构内容啊如果说你？\"],\"sn\":\"609814491781588844148\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.210188\n",
      "{\"corpus_no\":\"6824033672588706683\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"现在到底应该前端设计要多一点隐性还是显性的，这个反馈数据来解决我们的问题啊，各位稍微看一下啊，这一边就是更清楚的，哈哈，这个行业别的例子啊，什么事情，这些会什么隐性反馈啊，这边非常清楚的啊，我今天直接评分显示反馈，我今天读这一个不独这一个就是隐性啊，这边都是写的哈，这边就是有一个用户这些数据，然后这些数据怎么来的？再讲一遍前端工程师说说说我会做数据科学家说这个必须要做这个交互设计师说这个做了，对于我们交互设计的改进十分重要，产品设计跟产品经理，应聘人员说，有了这些改进，我们可以赚钱，可以赚更多用户可以干嘛的这些东西？\"],\"sn\":\"276837517231588844151\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.820082\n",
      "{\"corpus_no\":\"6824033685517434168\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"可能都把一些比较难的内容给删掉了，哈哈，我猜你们应该也有上啊，可是我建议你们还是稍微知道什么叫做长尾啊，因为这个常委的这个规律分布就是推荐系统的，这个一个核心的内容啊，那这个80%跟20%的一件事情呢？他的讲法就是这个意思，以前这这这有点行销学，可是她基本上是跟统计学同学同学绑在一起的内容以前你怎么推产品？以前你这种报纸跟电视的时候，我们卖的产品都是卖20%的热门品牌啊，因为她传统的东西现在呢现在我们大家都想要个人化的，而且互联网是不是有这么好的信息过滤系统？那我为什么要买个大众产品，我为什么不能买一个五？\"],\"sn\":\"9049906671588844155\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.059236\n",
      "{\"corpus_no\":\"6824033698286963716\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"结束讲完就好，那就是我，我就不细说了，你们可以阅读的好，那这边用户数据的内容呢，就是给各位，就是稍微你稍微记一下这些关键词哈比如说什么叫原始日志，什么是绘画日志，怎么展示日志之类的？因为这些东西呢，都有这个前端，还有这个交互设计人员都会碰到的东西把，再来这一个是比较这一个呃高层次的内容哈哈什么叫做显性什么叫隐性啊，这个显性隐性隐性讲白的就是说你写写信的意思是他点了他就喜欢啊，隐形的意思是什么他可能做了abcde这三个动作串起来跟cbdae他基本上有不同的这一个背后的高层次的这个意思啊？这就是隐性的。\"],\"sn\":\"913747415081588844157\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.761415\n",
      "{\"corpus_no\":\"6824033707054077738\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"真的推荐系统也算法，我们也要搞清楚业务的需求是吧，所以这一边的这个报告呢，还蛮重要的，对不对？然后这个编的那个东西呢，基本上就是拿用户跟行业跟产品经理出来的内容跟所谓的系统开发人员说不是没事找事做，给我乱做推荐系统，说这个东西有价值啊，千万不要别忘记这一门课是技术用户体验加这一个啊，商业的综合考量哈，所以呢，请记得这件事情，这一边有个关键的概念啊，这边这个是废话，好这个我就不想跟你们多说哈，这个也算是一个小废话，可是你至少把他的那个行业的重要内容就是你不。\"],\"sn\":\"863956708531588844160\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.858964\n",
      "{\"corpus_no\":\"6824033719803764696\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"就是整个礼拜我们都会开放啊，大家自己抽空时间呢，把自己之前所学的内容啊，就是考一考，然后如果说你觉得你有漏掉一些内容的，就是把笔记给作为作为累计作品及累计笔记啊这些东西呢，就是给各位训练你主动学习的这个东西啊，如果说每件事情都要我跟自己在那边天天用护肤，天天用这种嗯，就是检查的手段，你们累我也累啊那你也知道最终的检查都不是我们最最重检查，就是你自己的平时积累你去考试跟面试，还有你实际工作的时候你这一些知识能不能不经查找？而有快速的反应跟判断啊你也知道最重要的这个东西就是你的知识的内化还有。\"],\"sn\":\"770014648421588844163\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 11.880926\n",
      "{\"corpus_no\":\"6824033771294698493\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"那你再怎么做实验？离线实验都没有在线实验也没用，不如做文件调查，听到没有啊，所以呢，千万不要被记录人员或算法时代走啊，今天我们都在推荐系统，我是ab交互系统和平台系统有大数据有推荐的部分，我们出现问题的，我们第一步先问到底她是怎么样的问题？有怎样的指标，然后再问我们要干嘛啊，千万不要缘木求鱼，千万不要以为推荐系统就只是技术类，缘分算法师的事情，他不是好好这个评测维度就这些，哈哈，我时间应该已经超过，然后我一节课45分钟，现在7:35应该是吵了哈那后面的内容呢？嗯，我还我有被。\"],\"sn\":\"643981756661588844175\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Request time cost 3.061172\n",
      "{\"corpus_no\":\"6824033784327375742\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"好，这个app在这边有的没的有的没的对不对？好你点上去之后，它应该有一些标签，你看看标签哪来的这个标签就是用户提交问题跟提交答案的时候来的是吧？那你这个算不算交互的标签也算是吧？那这一些内容就是你做交互设计跟产品设计的一个重要的切入，然后你现在就打通这个这个关系了哈，你这个交互的切入，基本上他的数据又有可能有智能系统的来源好，那这边的内容就请各位一定要记得啊，这一边的如何？为什么如何打什么样就？\"],\"sn\":\"472152636911588844178\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.064633\n",
      "{\"corpus_no\":\"6824033797094377512\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"判断什么是好的好的定义到底从哪来？它的技术性定义跟社会型定义是什么？因为这是我们产品经理要或者用户交互媛媛摄设计人员是需要知道的吧，是吧，那我们来知道什么叫做好的，这是第一张嘛，也不难啊，什么叫做好的再来这个好的，跟用户的这个这个关系到底在哪里啊？所以你会发现用户行为数据更好的，这种基本上是绑在一起的话，等下我们看就知道哈，我们来看看什么是好的，好啊，滚滚滚哈，这个好的应用推荐系统呢？他基本上这本书这一个章节，我觉得我觉得写的还可以的部分就是他有技术指标啊，就是比较偏演算法跟我们这种所谓的这个计算机科学的指标，那他还有一个指他还有另外一个就是。\"],\"sn\":\"75359607141588844181\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.606435\n",
      "{\"corpus_no\":\"6824033810082906972\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"是吧，那所以我用这样的方式，各位来三减这一本书的主要内容，那就更不用讲说，唉，这一个作者，而不是这个这个这个蓄着企鹅在这些内容的，他就算是工程师背景，你也知道他的她的就是产品跟行业界的这个呃，内容呢基本上是非常跟用户数据跟用户讲啊，所以说我请各位我等一下就是花一节课的时间，这是api的课啊，也是推荐系统人工智能的课，那里面就有推荐系统那这个推api他已经包了一些演算法之类的内容，然后我们以后会做一个实践是不需要你懂演算法的直接这个这个那个呃呃，就是徐老师会带着。\"],\"sn\":\"534254590041588844184\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.713742\n",
      "{\"corpus_no\":\"6824033822847156211\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"大赛的时候都是看这些指标，直接指标，对于你来说最重要的东西就是准确率和召回率的意义是什么？数学代码不会没关系啊，我就直接跟你讲，这就是ac页面，我这边有奖，哈哈，在这个意思是什么呢？我今天推荐十个搜索已经结果这十个里面到底有多少是准确的，有哪些他是误判的，就是准确率我可以吧好再来你搜查这些内容，所谓的召回率的意思是什么呢？他是刚好跟准确率相对相相反的概念啊，不是完全相反，他应该想说交叉的概念啊！\"],\"sn\":\"470512122471588844187\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.147700\n",
      "{\"corpus_no\":\"6824033831667394827\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"第马克泰克那这个以市场营销科技，你看现在在猎聘在就是工作平台有多少的工作机会啊，多少的传统的广告工作机会就算你还是在做这些内容？你的团队跟老板会拿这些数据跟交付的内容说你要改进你的广告设计，那这个东西它的根本数据的来源根本跟他这些数据怎么透过计算产出平台跟交互界面需要的内容就是这里又是推荐系统啊？那这边推荐系统内容呢？呃，请各位就是要要了解哈这边这边那种。\"],\"sn\":\"557226650871588844189\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.487494\n",
      "{\"corpus_no\":\"6824033844400010496\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"我想要或者这个这个这个中国市场可能就只有20个人在买，我就是其中之一个是吧那所以呢，这个长尾商品的这个这个所谓的个性化需求，这一个是互联网行业在营销，甚至这几年的营销科技更夸张的走向了这一个走向超级常委的过程，这也是为什么搜索引擎打败了主要报纸的头条，现在变成热搜对不对？那个时候她就是什么推荐系统？现在再也不是南方周末或者南方日报的编辑跟你讲说第一个最重要的新闻是头版头，不是二板头，而是今天你们看到的热搜排行。\"],\"sn\":\"17208199191588844191\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.744731\n",
      "{\"corpus_no\":\"6824033857496557560\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"啊，这两期的问题就讲过了啊，就是没数据啊，怎么做推荐系统？那我们就是要累积数据那可是呃，没有好处，一些地方为什么要要要要要要要用你的数据啊，所以说就是这个问题啊，这边就是写了这个信息条件那里面这些内容呢，就给各位就是讲说原来可以收集这一些，比如说人口同学能考人口人口进行数据等等，但更好的是用户标签啊这边有的删掉了因为我觉得里面那种太复杂了然后再用户标签啊个人捅个人数据啊这些全部是大数据的这些内容来源呢我这个就不细讲了哈，这边就有这些呃用户的特征这个种类啊这边稍微大家记一下页面哈就是啊，这一个用户跟物品的这个这个系统这个部分啊，因为这东西就等于是一个重要的内容，你可以以以后对这些系统架构的时候可以帮助你系统性的思考，不会辣。\"],\"sn\":\"673559478461588844194\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.757197\n",
      "{\"corpus_no\":\"6824033870140142882\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"当然，这个不能算是很懂事，但是一般的业界，你看到mse马上就知道这是推荐系统技术被评分最重要的指标，这样就好了，我就不讲了，粑粑通常是0到1然后0.6就还勉强了0.99台型号，然后这个他本人这个扣扣跟bc省也要记啊，这个东西最重要的内容就是什么搜索引擎搜索引擎就是前十项推荐啊，这是关键搜索之后我就给你钱11或者是任何其他推荐都有所谓的前十推向了这件事情，或者前多少，所以他们按推荐这两个指标也是技术指标啊，这个计算机学会他们在办这个推荐系统和查询系统的，或者是系统的，或者是。\"],\"sn\":\"397049545761588844197\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.352353\n",
      "{\"corpus_no\":\"6824033882983011094\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"话跟应用的这个产生出来的高端判断啊这些东西呢？你当然可以说我实习时在训练，可是没有实习时候训练都是都是高成本的，没有一个公司，希望你在那个时候才慢慢学，现在你做这一些这一些笔记，跟做一些这些所谓你觉得无聊的这些活动基本上就是在除了记忆之外，更重要的就是你要形成判断那今天的这些内容呢我我们很大一部分的缺点不是补齐各位的技术型姿势，是古奇各位综合性的判断能力好，那希望各位好好珍惜把这一边的内容呢？以你能接受的方法。\"],\"sn\":\"196427581401588844200\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 4.853616\n",
      "{\"corpus_no\":\"6824033900157932821\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"你当成一个技术的难题就卡住啊，因为你是可以用一些创新的另类数据或是另类的交互想办法用交互就是有趣的方式给到数据，所以这边呢，你是不是就跳脱了这一种所谓数据跟演算法的局限？我们只要想办法搞到交互，然后这个交互想办法去一到这个推荐系统所需要的数据啊，那基本上就是这样啊，我要讲的这个就是这一节课基本上讲的就是这些内容，那我们后面的内容基本上就是细讲，为什么这一些东西是重要的？好，那我现在就是往前讲了，好像就是这一遍就是总结，然后咱们等级那那其实呢，听起来好像有点道理，但是呢，你容易忘记啊，我记忆建议各位。\"],\"sn\":\"749208175121588844204\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.046493\n",
      "{\"corpus_no\":\"6824033912981371817\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"这这是一个业务内容，而不是这是一个这是一个技术内容，为什么？因为技术的这些内容呢？他基本上前端工程师会帮你搞定，对吧？可是呢，这个优缺点是干嘛的？我们到底要怎么看我们的系统好不好？是不是我们的问题点可能不一样？那我们到底今天的问题点到底是要做离线实验用户调查干嘛的？我们是不是得要知道她优缺点啊？这个东西到底是谁？要知道是推荐系统的专家知道了吗？不是，就是董推荐系统在干什么的？产品经理，交互设计师，用户研究人员需要知道的好，那这一边就是你可能要稍微自己看一下，然后再在实验室有名就是ab测试哈。\"],\"sn\":\"107098800651588844207\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.854692\n",
      "{\"corpus_no\":\"6824033921572767477\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"就是训练量过多的时候才需要用啊，所以呢，这边都已经条件了啊，如果说你的物品就没多少，你打开就是20个物品，20个物品，除以你选简单的这个网页设计，我不是说一层4到7个选项，那你两层就结束了，对不对？两层七层749了，那你两层导航就结束了，你干嘛做推荐系统是吧啊，这个东西是非常重要的啊，先从需求出发，那你的信息量也不多的话，那你别搞这个东西是吧好再来就是这一边是比较商学院的，这个部分，可是这就是非常产品经理的这个导向的东西好再思考一下，为什么在一个非常技术的ac验推荐系统大会上？业界的人员会跟你说a，就算我们这边的人搞醉。\"],\"sn\":\"93263220361588844210\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.073455\n",
      "{\"corpus_no\":\"6824033934592041984\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"Api的那些内容去做这样的实践啊，就是如何拿这个数据上去，然后如何产出一些具有有趣的这个结果拿来作为交互系统的实践啊，随着转一遍用户行为跟交互系统需求，我们来看一下昨天系统到底能干嘛？好，那我们反过来读好，反过来读就是从他这本书的最后的这个部分啊，这个部分还蛮务实的，就是大家可能知道acmacan的计算机科学的回答，推荐系统，它本身有的专门做推荐系统大会好像是非常行业顶尖的会议呢？就算是这种非常技术跟实战的会议，他们也有人说，并不是每一个情况下都要用推荐系统。\"],\"sn\":\"603678730881588844212\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.322732\n",
      "{\"corpus_no\":\"6824033947452725397\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"嗯，就是代码的，跟就是代码跟这个演算法的东西，我们这边仔细讲一件事，就是上礼拜讲的内容，我们这边有一个蛮好的，这个宗就是就是总结啊，我这个地方我没有删啊，就是基于用户的更基于物品的，然后这个简称就是lcfcfiiii然后这个东西呢啊，我们还是留着啊，就虽然呃数学公司还是很碍眼，但是呢，我们只要知道这些内容就好啊，就是至少我们有个稍微深入的内容，基本上就算你不会代码，不会算法你至少讲出这个东西，别人都会认可你，你是至少这些系统入行的人啊，协同过滤算法里面这两种算法你是入行的人啊所以呢，先跟各位讲了，你已经没有太多的这个啊，就是恐惧感啊，就是我们这边呢就是刚刚讲的用户交互交互。\"],\"sn\":\"401629683711588844215\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Request time cost 5.521579\n",
      "{\"corpus_no\":\"6824033968829509326\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"计算机很容易做，那就是你你你又不能给他，就是很随随便的东西啊，给她随便的人就说你干嘛给我这个？你还给他新兴的东西，让他说，唉，这是我有兴趣的，她真的是有点难啊，所以呢，这个东西你就有机会，就算你不是技术人员，不是算法师啊，这个东西算是推荐系统一个难点啊，稍微记一下，让这个惊喜程度我不太喜欢这个翻译哈所以哈，所以问题应该是嗯嗯，就是嗯嗯怎么叫塞翁失马焉焉知非福的这个是幸运的感觉啊那所以呢？这个这个真的有点有点难说啊，可是这东西真的还蛮重要的哈，这边又说了哈没有公司啊，但是只是一个定性而不是定量的度量方法，可是你要知道惊喜成。\"],\"sn\":\"854606522941588844221\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.413004\n",
      "{\"corpus_no\":\"6824033986070030428\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"上面的重要来源，那这些东西你先就得记得了，这些行为数据和标签数据都有可能大量收集之后做出更好的交互系统，然后这个交系统的其中有一个最大可能就是推荐系统，那这个推荐系统要做得好的话，必须要足够多的用户标签跟用户行为，如果一刚开始没有用户标签也没有用户，是因为数据那这个东西叫做系统的人启动好，这个是蛮重要的一个内容啊，我现在已经给各位就是简要的就是总结这方面的知识，然后你会发现这边会有一堆演算法跟这些内容我已经删掉了啊，所以呢，你就不要太担心，那我从标题。\"],\"sn\":\"983588229661588844224\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.494029\n",
      "{\"corpus_no\":\"6824033994799719989\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"这一个状况来看，推荐系统，这是他的用户的这个部分，所以说我们看这本书之前呢，我已经给各位就是三减了啊，就是删掉很多，看起来很可怕的就是公司啊或者图表啊，那就是请各位就是要区分就是我们这边的培训呢，因为其实有很多人在这个就是就是问卷上面写错，就是这边的课就是代码很多有的没的啊，我们要这样讲哈就是代码很大一部分是一个是读的能力就是你要能读就好像你在读文章，你不一定要读董读懂，或者能写文言文，但是呢，你看到文言文应该至少基本的这个阅读能力啊我们我们的最基本的能力应该是在这里哈那拍？\"],\"sn\":\"92881374391588844227\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.690374\n",
      "{\"corpus_no\":\"6824034003311597572\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"赵曼老师分享给各位的这些啊，就是新一代互联网设计的人才，这些东西根本就不算是代码，好多都是简单的东西，好的，这学期也没有这些事，那就是pppppp东西我根本就没有教你们男的东西啊，所以说呢，趁这个机会跟各位讲一下哈，那这个这个文档呢？请各位翻到最后面啊，就是互联网跟新媒体有又能回答说诶，我们都是不担心媒体只谈这个网络，那你怎么解释推荐系统呢？你怎么推？你怎么解释这些这些这这些所谓的这个业界人士？他们怎么看待这些内容？我们到底不把这个社交媒体跟推荐系统不当成信息媒体吗？哦，你会发现我今天各位推荐系统这个实在里面呢，里面它我们先看这个目录好的。\"],\"sn\":\"406136851691588844229\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.170993\n",
      "{\"corpus_no\":\"6824034020521441468\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"就是给各位讲，就是有不同行业的差别，那评测的部分啊，你会发现有这样的东西啊那这一边呢，就是标准的这个啊，产品经理的概念啊，所有的多方利益关系嘛，对对对对对对对对对对对对对对对对对对对对，最近屙唔小时候在讲嘛，对不对那这个第三方内容提供方萍萍用用户跟网站啊？这边这是他的认为啊，这本书的作者认为要我的话我会直接把网站改成平台，然后这个平台的这个需求方跟供给方啊，将来会更广，基本上嗯，就是平台经济这个概念可能更更更更更普适性的啊好这边那种就是给各位稍微就是讲一下呃，这一边的指标有这一些哈你稍微可能写个笔记记下来哦，虽然这个我不会考机考，但是呢？\"],\"sn\":\"997026997531588844233\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 524288}\n",
      "Request time cost 1.847303\n",
      "{\"corpus_no\":\"6824034033230616370\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"一些笔记本分享出来，然后希望各位就是能继续的就是撑下去啊，这学期才过了1/3，快到1/2了，请各位好好的学习啊，把把这是这几门课，不同的内容，稍微作作一些整合和交叉，思考隐就是因为把你这个这个所谓的行业的这种成熟判断，不断的提升啊，谢谢各位。\"],\"sn\":\"483692926901588844236\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.383294\n",
      "{\"corpus_no\":\"6824034042043893394\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"新媒体的课更应该上这种推荐系统，而不只是停留在报刊编辑排版的课，对吧报刊编辑的排版的重要性，是因为我们在之前拿到报纸的时候，头版头就是头版的头条是最重要的，这还是二版头条在干嘛干嘛干嘛现在呢？现在是搜索引擎结果的排名，跟这些平台的大众推荐系统的排名更为重要，是吧？那这一边你看到了就是多方的设计的冲突，原来的平面和视觉设计变成了信息设计哦，所以呢，这边最大转换就是推荐系统就是这一个锁。\"],\"sn\":\"843535345511588844238\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.576653\n",
      "{\"corpus_no\":\"6824034054831095703\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"Ab，测试的主要介绍，强烈推荐那个位，奈奈耐心就是学习啊，因为这东西是产业的东西，然后这一本书的学术水平跟行业水平，算是在中国中文的出书来讲算是蛮ok的啊，所以说我没有，就是三座，经过三姐给各位看啊，这个评测指标，这个用户满意度就是我们标准用户研究的内容啊，我们我们我们我们就不多说了然后这预测的准确度啊，这个是比较技术型的啊，这个技术型的指标推进氢系统就两个关键词，你记下来啊，这个是最重要的啊，均方根差误差哈啊，你不需要知道什么均方根你只要知道一件事情哈，我就是跟你讲，你如何假装专业哈，你只知道看到imse啊办。\"],\"sn\":\"16656569121588844241\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.917854\n",
      "{\"corpus_no\":\"6824034067803663503\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"这个能启动的事情呢？等一下，我们会细说啊，这个人启动的事情呢，基本上他只是一个平台经济的启动的这一个小问题啊，也就是说，平台经济的启动本来就是一个比较难的问题，蛋生鸡生蛋的问题，我们上平台经济这门课的时候就会讲这个平台需要做到所谓的网络效应，但是呢，一刚开始两两手空空就是冷启动的问题，哈，那在这边讲人启动很大一部分是这个推荐系统这个专业人是喜欢讲的人，启动那基本上在平台经济这边呢，就是一样的问题，而且他这个平台经济的这个所谓的这个但先有蛋还是先有鸡先有鸡的这个问题，这个是包含的这个人启动的问题哈，这边已经讲了不要。\"],\"sn\":\"695213337011588844244\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.277915\n",
      "{\"corpus_no\":\"6824034080546493495\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"啊，这边有没有看啊？这个重点就很重要很重要很重要的啊，所以说为什么我要花的时间给各位上一下，这个课好不？然后我就全部给你们烤就好了是吧？然后呢？这一边这本书的各章节就会跟你说诶，这些东西数这些数据从哪来？怎么算啊？从哪来的意思就是出发出发点啊？这个出发点就是有一些学科的基础啊，不管是就是就是就是啊就是啊，认知科学的这个行为学或者是这个呃，信息管理的那个这个三啊都有啊那这一边的指标计算方法呢？就算你不懂他的也算法，你只要知道它的输入跟输出是干嘛就好了，他到底是要输入啊，我们去做问卷，得到一些文本还是？\"],\"sn\":\"452142196201588844247\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.740766\n",
      "{\"corpus_no\":\"6824034089150797151\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"我每次上这一门课期末项目的时候就会有一堆人，我其实一七集在这部分我上课的时候就是我气到不行，他我都忘了他们，其实177所以我有很多情绪上的反应都是因为上api的课啊，因为太多人脱裤子放屁啊我我都已经不是这么继续懂技术，但是我不是那么技术人员的你今天作为彩笔记，你会用户交互交互设计人员，我说要做智能，那你就应该要用户体验的方式来问，到底这个智能的东西有没有解决用户的实际问题？还是只为了用而用啊，我们一定要说a到底需不需要啊？所以说这边有句话非常重要，你一定要知道这件事情，推荐系统在什么时候才去？\"],\"sn\":\"861135830711588844249\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.442268\n",
      "{\"corpus_no\":\"6824034102089542395\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"看起来所有的这个团队内容啊，这就是用户行为的这个部分啊，这个请各位真的么？好好的把它弄起来啊，这个就跳过啊，这边就跳过，这边有点难啊，基本上就是为一分不给你看一看，然后这个用户这边好，这边还是那边你就记下来就好了哈，这边没什么话说，就是我们上礼拜讲的哈，基于用户根据一物品，然后呢，会有一些也算法，然后这些都是演算法啊这些算法嗯，就当做没看到，或者当做你有看到，然后你知道我这边可以查找，可以装配装牛逼啊，其他其实其实对你来讲不是那么重要，然后这边就有这个呃，基于用品跟基于这个用户的这个差别这个这个这个所谓的这个指标的结果啊，这些都是行业的，这个累积多年的这个这个总结啊可以稍微看一下啊，特别像什么新闻文化味稍微看看看切对啊啊！\"],\"sn\":\"447934021991588844252\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.396575\n",
      "{\"corpus_no\":\"6824034119135163036\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"比前面两个指标都简单，我也不说了啊，那新颖性呢？这边就是稍微有点难处的东西啊，这个算法也有点难哈，那基本上可是这个研究容易做啊就是啊，你给这些推荐他到底有没有没有这东西这东西啊？我觉得好这个东西呢也是蛮重要的，那这一边就讲了啊准确统计这个新颖性，需要做用户调查啊讲到这边应该很清楚的一件事情，就是推荐系统并并不是程序员或演算法独占的东西，他既然这么靠用户数据看靠靠交付他是不是有一些东西？技术人员根本把持不到像这个新颖性是吧，这个心理性已经算是个学术难点然后呢他医院这东西本来就有点麻烦，就是因为你椅子的东西，找椅子。\"],\"sn\":\"748161090941588844256\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.797144\n",
      "{\"corpus_no\":\"6824034136627120673\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"明天开始看啊，这些内容到底是什么？你会认定一次他的互联网产品还是还是社交没媒体的一部分，如果说这东西已经认识他是设置了媒体一部分的话，那你就会知道说这些东西就是我们正在交的新媒体啊，特别是社交媒体和新媒体的这个部分，这也是目前国外这一个所以新媒体这个学科最重要的内容啊，那所以呢嗯，我得要为自己辩护一下哈这个这个部分我们当然不一定要把代码给各位弄清楚，但是聊到这个对象是什么？然后之前内容呢？不管是覆盖率，满意度ab测试，她基本上就是用户行为本身的你们看到啊，所以呢，推荐系统，它的重要的地方啊，不一定是推荐系统的。\"],\"sn\":\"252142826601588844260\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Request time cost 7.528466\n",
      "{\"corpus_no\":\"6824034170888721782\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"必修课的部分，如果你不上前端，那基本上只有停留在就是htmlcssroy跟拍粉作为一个基础的编程语言啊，那这一边呢，就根本上来说并没有要求各位一定要会编程，那如果说你是选择不想要学编程，但是你至少要能读懂编程的人在干嘛？然后编程的专业在干嘛？然后我们这边呢教的编程全部都不是编程思维的都是设计思维或者是这一个叫做什么数数据思维那atmwss？如果你们还认为那些代码的话，那我就没有话说了哈，那天没有实验室的东西都是设计的一部分。\"],\"sn\":\"6474529551588844268\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 3.504258\n",
      "{\"corpus_no\":\"6824034183669008145\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"今天我讲这个内容你就应该要有这一个想法，今天有听的，一听到标签系统，你就会马上意识到正在收集数据，这个数据收集完可以做智能的推荐系统，再来一个推荐系统做出来的，而延伸推荐可以变成你这一个新的这个交互的可能是吧，这就是所有基本上你你你天天在用的app的所有的这个很常见的根本哦，不管是推你，你可能想约会的对象下你可能想要买的东西都是这样ok好，那我们就来跟各位稍微进去讲一下我们什么叫做好的啊，这边的东西这边的内容呢，我们就不跟各位细谈。\"],\"sn\":\"385364742371588844271\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.468977\n",
      "{\"corpus_no\":\"6824034196484147472\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"那非常有可能你今天就去世界的时候，他们要给你评价他们的这个网站vipp的时候，他本质上就它的底层就是大数据推荐系统的话，那你就知道，至少至少知道有个有个社会科学家科技的这一个指标体系，然后这些指标体系呢，至少你看得懂你看到这个qq望文生义的是吧，你至少拿到这个东西，然后你至少我这本书收集起来你写出产品报告或产品改进报告的时候，你就来源呢对吧然后呢，他这边就有说了，这就是一个用户研究的特殊性啊，看一下她这边有没有写了这些指标中啊？这嘟嘟嘟嘟用户数据跟这个用业务数据哈，有一些可以离线计算，有一些可只能在线计算，有一些只能透过用户问。\"],\"sn\":\"78720928261588844274\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 4.586429\n",
      "{\"corpus_no\":\"6824034205301766321\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"系统基本上跟用户的行为，跟用户的标签行为直接相关，好，那我就要问一个问题了，那要不然行为出去哪来的交互界面来的平台设计来的那用户的标签发来的也是一样啊？只是用户的这个标签是一个比较明显的分类问题啊，给用户做分类给用户做标签的问题，那甚至用户行为数据呢？就是所谓的大数据，所谓的什么数据废气对不对？你们今天今天都爱上应该都上过大数据对不对？就是背景的大数据，我们今天随便逛逛网页，他就给你弄个窟窿可以，然后他就哭了，可以就会议就会一起去给你要给你寄信给你寄一些一些事情啊，这些都是推荐系统的根本啊，也是用户就是数据或者用户大数据在网。\"],\"sn\":\"639233882591588844276\"}\n",
      "\n",
      "url is http://vop.baidu.com/server_api?cuid=123456PYTHON&token=24.2a58cdb664863cfbd5a504956a69d14c.2592000.1591436084.282335-15803531&dev_pid=1537\n",
      "header is {'Content-Type': 'audio/m4a; rate=16000', 'Content-Length': 944840}\n",
      "Request time cost 2.965710\n",
      "{\"corpus_no\":\"6824034226478855449\",\"err_msg\":\"success.\",\"err_no\":0,\"result\":[\"呃，这个呃，所谓的心理程度是不一样的事情啊，心里只是时间序列，跟他是不是在你的数据集中曾经出现过？然后呢？这个啊，惊喜程度呢？基本上是一个嘟嘟嘟嘟嘟嘟嘟嘟，讲这个社会科学的讲法的话，他是一个我还蛮喜欢这概念我我的博士论文超喜欢这概念，哈哈，他是一个呃，他是一个我们人生中趣味的来源啊，我们为什么想找找找新朋友，都是来自于这个东西啊，那信用程度，我们就我们就不多讲了哈，就跟跟你讲啊，这个东西真的是很烦人的东西啊啊，这个东西有点难啊，可是呢嗯，诺诺你产品做得好的话，这东西可能是你的这个宝典啊，再来信任度，现在肚子这个部分呢？特别是在于这个啊，就是有有没有就是诈骗？\"],\"sn\":\"87868613581588844281\"}\n",
      "\n"
     ]
    }
   ],
   "source": [
    "# coding=utf-8\n",
    "\n",
    "import sys\n",
    "import json\n",
    "import time\n",
    "\n",
    "IS_PY3 = sys.version_info.major == 3\n",
    "\n",
    "if IS_PY3:\n",
    "    from urllib.request import urlopen\n",
    "    from urllib.request import Request\n",
    "    from urllib.error import URLError\n",
    "    from urllib.parse import urlencode\n",
    "\n",
    "    timer = time.perf_counter\n",
    "else:\n",
    "    import urllib2\n",
    "    from urllib2 import urlopen\n",
    "    from urllib2 import Request\n",
    "    from urllib2 import URLError\n",
    "    from urllib import urlencode\n",
    "\n",
    "    if sys.platform == \"win32\":\n",
    "        timer = time.clock\n",
    "    else:\n",
    "        # On most other platforms the best timer is time.time()\n",
    "        timer = time.time\n",
    "\n",
    "API_KEY = 'kVcnfD9iW2XVZSMaLMrtLYIz'\n",
    "SECRET_KEY = 'O9o1O213UgG5LFn0bDGNtoRN3VWl2du6'\n",
    "\n",
    "# for audio_file in os.listdir(path):\n",
    "#     # 需要识别的文件\n",
    "#     AUDIO_FILE = './rest-api-asr/python/audio/liao_audio/'+audio_file # 只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "#     # 文件格式\n",
    "#     FORMAT = AUDIO_FILE[-3:];  # 文件后缀只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "\n",
    "CUID = '123456PYTHON';\n",
    "# 采样率\n",
    "RATE = 16000;  # 固定值\n",
    "\n",
    "# 普通版\n",
    "\n",
    "DEV_PID = 1537;  # 1537 表示识别普通话，使用输入法模型。根据文档填写PID，选择语言及识别模型\n",
    "ASR_URL = 'http://vop.baidu.com/server_api'\n",
    "SCOPE = 'audio_voice_assistant_get'  # 有此scope表示有asr能力，没有请在网页里勾选，非常旧的应用可能没有\n",
    "\n",
    "#测试自训练平台需要打开以下信息， 自训练平台模型上线后，您会看见 第二步：“”获取专属模型参数pid:8001，modelid:1234”，按照这个信息获取 dev_pid=8001，lm_id=1234\n",
    "# DEV_PID = 8001 ;   \n",
    "# LM_ID = 1234 ;\n",
    "\n",
    "# 极速版 打开注释的话请填写自己申请的appkey appSecret ，并在网页中开通极速版（开通后可能会收费）\n",
    "\n",
    "#DEV_PID = 80001\n",
    "#ASR_URL = 'http://vop.baidu.com/pro_api'\n",
    "#SCOPE = 'brain_enhanced_asr'  # 有此scope表示有asr能力，没有请在网页里开通极速版\n",
    "\n",
    "# 忽略scope检查，非常旧的应用可能没有\n",
    "# SCOPE = False\n",
    "\n",
    "\n",
    "# 极速版\n",
    "\n",
    "class DemoError(Exception):\n",
    "    pass\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN start \"\"\"\n",
    "\n",
    "TOKEN_URL = 'http://openapi.baidu.com/oauth/2.0/token'\n",
    "\n",
    "\n",
    "def fetch_token():\n",
    "    params = {'grant_type': 'client_credentials',\n",
    "              'client_id': API_KEY,\n",
    "              'client_secret': SECRET_KEY}\n",
    "    post_data = urlencode(params)\n",
    "    if (IS_PY3):\n",
    "        post_data = post_data.encode('utf-8')\n",
    "    req = Request(TOKEN_URL, post_data)\n",
    "    try:\n",
    "        f = urlopen(req)\n",
    "        result_str = f.read()\n",
    "    except URLError as err:\n",
    "        print('token http response http code : ' + str(err.code))\n",
    "        result_str = err.read()\n",
    "    if (IS_PY3):\n",
    "        result_str = result_str.decode()\n",
    "\n",
    "    print(result_str)\n",
    "    result = json.loads(result_str)\n",
    "    print(result)\n",
    "    if ('access_token' in result.keys() and 'scope' in result.keys()):\n",
    "        if SCOPE and (not SCOPE in result['scope'].split(' ')):  # SCOPE = False 忽略检查\n",
    "            raise DemoError('scope is not correct')\n",
    "        print('SUCCESS WITH TOKEN: %s ; EXPIRES IN SECONDS: %s' % (result['access_token'], result['expires_in']))\n",
    "        return result['access_token']\n",
    "    else:\n",
    "        raise DemoError('MAYBE API_KEY or SECRET_KEY not correct: access_token or scope not found in token response')\n",
    "\n",
    "\n",
    "\"\"\"  TOKEN end \"\"\"\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    token = fetch_token()\n",
    "\n",
    "    \"\"\"\n",
    "    httpHandler = urllib2.HTTPHandler(debuglevel=1)\n",
    "    opener = urllib2.build_opener(httpHandler)\n",
    "    urllib2.install_opener(opener)\n",
    "    \"\"\"\n",
    "    for audio_file in os.listdir(path):\n",
    "        # 需要识别的文件\n",
    "        AUDIO_FILE = '../_week08_/audio/'+audio_file # 只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "        # 文件格式\n",
    "        FORMAT = AUDIO_FILE[-3:];  # 文件后缀只支持 pcm/wav/amr 格式，极速版额外支持m4a 格式\n",
    "        speech_data = []\n",
    "        with open(AUDIO_FILE, 'rb') as speech_file:\n",
    "            speech_data = speech_file.read()\n",
    "        length = len(speech_data)\n",
    "        if length == 0:\n",
    "            raise DemoError('file %s length read 0 bytes' % AUDIO_FILE)\n",
    "\n",
    "        params = {'cuid': CUID, 'token': token, 'dev_pid': DEV_PID}\n",
    "        #测试自训练平台需要打开以下信息\n",
    "        #params = {'cuid': CUID, 'token': token, 'dev_pid': DEV_PID, 'lm_id' : LM_ID}\n",
    "        params_query = urlencode(params);\n",
    "\n",
    "        headers = {\n",
    "            'Content-Type': 'audio/' + FORMAT + '; rate=' + str(RATE),\n",
    "            'Content-Length': length\n",
    "        }\n",
    "\n",
    "        url = ASR_URL + \"?\" + params_query\n",
    "        print(\"url is\", url);\n",
    "        print(\"header is\", headers)\n",
    "        # print post_data\n",
    "        req = Request(ASR_URL + \"?\" + params_query, speech_data, headers)\n",
    "        try:\n",
    "            begin = timer()\n",
    "            f = urlopen(req)\n",
    "            result_str = f.read()\n",
    "            print(\"Request time cost %f\" % (timer() - begin))\n",
    "        except  URLError as err:\n",
    "            print('asr http response http code : ' + str(err.code))\n",
    "            result_str = err.read()\n",
    "\n",
    "        if (IS_PY3):\n",
    "            result_str = str(result_str, 'utf-8')\n",
    "        print(result_str)\n",
    "        with open(\"../_week08_/text/\"+audio_file[0:-4]+\".txt\", \"w\") as of:\n",
    "            of.write(result_str)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 思考和额外练习：如何把图灵微信公众号文本自动回复转变成语音自动回复？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "312.59375px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
